/**
 * @file utils.c
 *
 * @brief Miscellaneous supplementary stuff
 *
 */

#include <stdio.h>
#include <process.h>
#include <time.h>
#include "utils.h"


/**
 * @brief Returns the number of seconds since the first call
 *
 * @return The number of seconds
 */
uint32_t cur_time(void)
{
    static uint32_t init_time = 0;

    if(!init_time) {
        init_time = time(NULL);
        return 0;
    }

    return time(NULL) - init_time;
}

/**
 * @brief Use the PID to set the window group id.
 *
 * @return String containing the window group id
 */
const char* get_window_group_id(void)
{
    static char s_window_group_id[16] = "";

    if(s_window_group_id[0] == '\0') {
        snprintf(s_window_group_id, sizeof(s_window_group_id), "NAF%d", getpid());
    }

    return s_window_group_id;
}

